package com.sztx.pay.center.core.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;

import com.sztx.pay.center.core.service.SettleService;
import com.sztx.pay.center.dataaccess.dao.mysql.UserInfoMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.redis.UserRedisDAO;
import com.sztx.se.core.service.StartupCallback;

public class StartupCallbackSettleImpl implements StartupCallback {
	
	private Logger logger = LoggerFactory.getLogger(StartupCallbackSettleImpl.class);
	
	@Autowired
	private UserInfoMysqlDAO userInfoMysqlDAO;	
	@Autowired
	private UserRedisDAO userRedisDAO;
	@Autowired  
	private TaskExecutor taskExecutor;// 线程池  
	@Autowired
	private SettleService settleService;
	@Override
	public void businessHandle() {
		
		logger.info("启动完成, 准备结算");
		
		initGrayUser();
	}

	
	
	private void initGrayUser(){		
		logger.info("启动完成,开始结算");
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		taskExecutor.execute(new SyncBindCardInfo());
		logger.info("启动完成,结束结算");		
	}
	
	class SyncBindCardInfo implements Runnable{


		@Override
		public void run() {
			settleService.settlingOrders();
		}	
	}
	
	
}
